from gremlin_python import statics
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.structure.graph import Graph
from gremlin_python.process.traversal import T
from gremlin_python.process.traversal import Order
from gremlin_python.process.traversal import Cardinality
from gremlin_python.process.traversal import Column
from gremlin_python.process.traversal import Direction
from gremlin_python.process.traversal import Operator
from gremlin_python.process.traversal import P
from gremlin_python.process.traversal import TextP
from gremlin_python.process.traversal import Pop
from gremlin_python.process.traversal import Scope
from gremlin_python.process.traversal import Barrier
from gremlin_python.process.traversal import Bindings
from gremlin_python.process.traversal import WithOptions






def path_code_not_contain_error(g,string,paths):
    error_paths={}
    for key in paths:
        path = paths[key][0]
        is_right =True
        for node in path:
            node_id = node.id
            node_ast = g.V(node_id).ast.toList()[0]
            node_code = g.V(node_id).code.toList()[0]
            node_lineo = g.V(node_id).lineo.toList()[0]
            if string in node_code:  ## 判断是否有符合要求的节点
                is_right = not is_right
        if not is_right:
            if key in error_paths:
                error_paths[key]+=path
            else:
                error_paths[key] =path
    return error_paths

def path_code_contain_error(g,string,paths):
    error_paths={}
    for key in paths:
        path = paths[key][0]
        is_right =False

        for node in path:
            node_id = node.id
            node_ast = g.V(node_id).ast.toList()[0]
            node_code = g.V(node_id).code.toList()[0]
            node_lineo = g.V(node_id).lineo.toList()[0]
            if string in node_code:  ## 判断是否有符合要求的节点
                is_right = not is_right
        if not is_right:
            if key in error_paths:
                error_paths[key]+=path
            else:
                error_paths[key] =path
    return error_paths
